﻿/*
*  系统设置HOME
*/

var classmodel = angular.module("honorHome", ['Common', 'loadModule'])
.controller("honorHomeController", ["$rootScope", "$scope", "$location", "sysUserInfo", "$document", 'Msg', '$http', '$state', function ($rootScope, $scope, $location, sysUserInfo, $document, Msg, $http, $state) {
    $scope.childobj = function () {
        var obj;
        angular.forEach($rootScope.rootscopeauthority, function (data, index, array) {
            if (data.id == "9f657d804133edb3d66f3c3f53382937") {
                obj = data;
            }
        });
        return obj;
    }
    $scope.playUrl = function (url) {
        $rootScope.secparstr = url;
        $state.go($rootScope.secparstr);
    }
    $scope.personnelauthority = $scope.childobj().childroute;

    var navigalist = $scope.personnelauthority;
    var paramflag = false;
    var paramname = "";
    for (var i = 0; i < navigalist.length; i++) {
        if ($rootScope.secparstr != "" && navigalist[i].name.indexOf($rootScope.secparstr) >= 0) {
            $scope.playUrl(navigalist[i].name);
            paramflag = true;
        }
        if (navigalist[i].index == 0) {
            paramname = navigalist[i].name;
        }
    }
    if (!paramflag) {
        if (paramname != "") {
            $scope.playUrl(paramname);
        } else if ($rootScope.homeparams != "" && $rootScope.homeparams != undefined) {
            $scope.playUrl($rootScope.homeparams);
        } else {
            $scope.playUrl(navigalist[0].name);
        }
    }
} ]);
